<?php
/**
 * @version 	$Id: fQuery.class.php 74 2010-03-17 06:48:21Z mylifeisskidrow@gmail.com $
 * @author 		$Author: mylifeisskidrow@gmail.com $
 * @copyright 	Copyright (c) 2010 Luu Trong Hieu. All right reserved.
 * @license 	GNU/GPL see license.php
 */

defined('IN_FLYWHEEL') or die('Restricted Access!');
/**
 * Query
 * 	class danh cho viec build query
 * 
 * @package 	system
 * @subpackage 	databases
 *
 */

class fQuery {
	protected $_parts = array();
	private $table;
	
	public function __construct($table) {
		$this->table = $table;
	}
	
	public function select($select = null) {
		if ($select == null || $select = '*') {
			//Get table columns			
		}
		if (!is_array($select)) {
			$select = explode(', ', $select);
		}
		$this->_parts['COLUMN'] = $select;

		return $this;
	}
	
	public function distinct($alias) {
		$this->_parts['DISTINCT'] = $alias;
		return $this;
	}
	
	public function from($name) {		
	}
	
	public function where() {
		return $this;
	}
	
	public function groupBy($spec) {
		return $this;
	}
	
	public function innerJoin() {				
	}
	
	public function leftJoin() {}
	
	public function crossJoin() {}
	
	public function fullJoin() {}
	
	public function rightJoin() {}
	
	public function order($spec) {		
		return $this;
	}
	
	public function limit($start = null, $offset = null) {
		$this->_parts['LIMIT_START'] = (int) $start;
		$this->_parts['LIMIT_OFFSET'] = (int) $offset;
		return $this;
	}
	
	protected function _join() {}
	
	protected function builSelectQuery() {
		$sql = 'SELECT ' . implode(', ', $this->_parts['COLUMNS'] )
			. 'FROM ' ;				
	}
	
}